package com.github.chirspan.xaas.log.event;

import com.github.chirspan.xaas.log.feign.ILogClient;
import com.github.chirspan.xaas.log.model.ApiLog;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;


/**
 * @author lengleng
 * 异步监听日志事件
 */
@Slf4j
@AllArgsConstructor
public class ApiLogListener {

	private final ILogClient logClient;

	@Async
	@Order
	@EventListener(ApiLogEvent.class)
	public void saveSysLog(ApiLogEvent event) {
		ApiLog log = (ApiLog)event.getSource();
		logClient.saveLog(log);
	}
}
